import random
from http import HTTPStatus
from dashscope.api_entities.dashscope_response import Role
import dashscope

dashscope.api_key = "xxxxxxxxxxxxxxxxx"   # 请将此处替换为自己的API Key

def simple_multimodal_conversation_call(img,question):
    messages = [
        {
            "role": "user",
            "content": [
                {"image": f"{img}"},
                {"text": f"{question}"}
            ]
        }
    ]
    response = dashscope.MultiModalConversation.call(model='qwen-max-1201',
                                                     messages=messages)
    if response.status_code == HTTPStatus.OK:
        print(response.output.choices[0]['message']['content'][0]['text'])
    else:
        print(response.code)
        print(response.message)


img = 'https://tse2-mm.cn.bing.net/th/id/OIP-C.g9UbVfyVZX-SfD09JcYr5QHaEK?rs=1&pid=ImgDetMain'
text = '这是什么？'
simple_multimodal_conversation_call(img, text)

